#include <iostream>
#include <fstream>
#include "FileCPP.h"
#include "color.h"
#include "MyException.h"

FileCPP::FileCPP()
{
  this->_filename = "default.cpp";
  File_open();
}

FileCPP::FileCPP(std::string const& f)
{
  this->_filename = f;
  File_open();
}

FileCPP::~FileCPP()
{
  this->_FileCPP.close();
}

void	FileCPP::File_open()
{
  this->_FileCPP.open(this->_filename.data());
  if (!_FileCPP)
    throw new MyException (INPUT_FILE + this->_filename);
  std::cout << green << "Creating File " << this->_filename <<  "..." << white << std::endl;
}

void	FileCPP::writeLine(std::string const& w)
{
  this->_FileCPP << w << std::endl;
  std::cout << blue <<"Writed : " << w << white << std::endl;
}
